package org.evan.spring6.resources;

import org.springframework.core.io.FileSystemResource;

import java.io.IOException;
import java.io.InputStream;

//访问系统资源
public class FileSystemResourceDemo {

    public static void main(String[] args) throws IOException {

        loadFileResource("D:\\.java17.intellij");
    }

    private static void loadFileResource(String path) throws IOException {
        //创建对象
        FileSystemResource resource = new FileSystemResource(path);

        System.out.println(resource.getFilename());
        System.out.println(resource.getDescription());
        InputStream in = resource.getInputStream();
        byte[] bytes = new byte[1024];
        while (in.read(bytes) != -1) {
            System.out.println(new String(bytes));
        }
    }

}
